package org.xiaojinlong.exam;

import java.util.Scanner;

/**
 * @author Jin Long
 * 2015/9/25
 */
public class Didi {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String input = scanner.nextLine();
            String[] lines = input.split(";");
            String[] line1 = lines[0].split(" ");

            int[][] matrix = new int[lines.length][line1.length];
            for (int i = 0; i < lines.length; i++) {
                String[] line = lines[i].split(" ");
                for (int j = 0; j < line.length; j++) {
                    matrix[i][j] = Integer.parseInt(line[j]);
                }
            }

            int max = 0;
            for (int i = 0, len1 = matrix.length - 1; i < len1; i++) {
                for (int j = 0,len2 = matrix[0].length - 1; j < len2; j++) {
                    int tmp = matrix[i][j] + matrix[i][j+1] + matrix[i+1][j] + matrix[i+1][j+1];
                    if (tmp > max) {
                        max = tmp;
                    }
                }
            }

            System.out.println(max);
        }
    }
}
